-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle np.array(DataIO) for numpy in py38 #248
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #248 +/- ##
=====================================
Coverage ? 70.3%
=====================================
Files ? 33
Lines ? 5938
Branches ? 1394
=====================================
Hits ? 4175
Misses ? 1328
Partials ? 435 Continue to review full report at Codecov.
|
src/hdmf/data_utils.py
Outdated
@@ -626,6 +626,8 @@ def __bool__(self): | |||
|
|||
def __getattr__(self, attr): | |||
"""Delegate attribute lookup to data object""" | |||
if attr == '__array_struct__': # np.array() checks __array__ or __array_struct__ attribute dep. on version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean delegation of __array__
is allows but delegation of __array_struct__
is not? I.e., depending on the version of numpy we allow conversion of DataIO to a numpy array or not? Could you clarify what the problem with the __array_struct__
method is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake. The error should only be thrown if the object is not self.valid. I have added that back.
To clarify: def __array_struct__(self):
if not self.valid:
raise InvalidDataIOError("Cannot convert data to array. Data is not valid.")
return self.__array_struct__() I would get the error: |
Partially address #245